<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/6
 * Time: 10:15
 */

namespace app\api\controller;


use cmf\controller\HomeBaseController;
use think\Db;

/**
 * Class StatementController
 * @package app\api\controller
 * 一合说法模块
 */
class StatementController extends HomeBaseController
{

    /**
     * 小剧场列表
     */
    public function theatre()
    {
        $number = request()->param('number');

        $list = Db::name('theatre')->where('status',1)->order('create_time desc')->paginate($number);

        return_json(1,'获取数据成功',$list);
    }


    /**
     * @throws \think\exception\DbException
     * 图片返回接口
     * number    一页数量
     * type      类型 1为一合荣耀 |２为当先律趣
     */
    public function lv_qu()
    {
        $number = request()->param('number');
        $type = request()->param('type');

        if ($type == 1) {
            $list = Db::name('image')->where('status',1)->where('type',$type)->order('create_time desc')->paginate($number);
        } else {
            $list = Db::name('image')->where('status',1)->where('type',$type)->paginate($number);
        }

        return_json(1,'获取数据成功',$list);
    }

    /**
     * @return \think\response\View
     * 热点话题
     */
    public function hot()
    {
        //每页条数
        $number = request()->param('number');
        $id = Db::name('portal_category')->where('name','热点话题')->value('id');
        $ids = Db::name('portal_category_post')->where('category_id',$id)->column('post_id');
        $case_list = Db::name('portal_post')->where('id','in',$ids)->where('delete_time',0)->order('post_hits desc')->paginate($number);

        return_json(1,'获取数据成功',$case_list);

    }

}